package router

import (
	"github.com/gin-gonic/gin"

	"mxshop-api/goods-web/api/category"
	"mxshop-api/goods-web/global"
	"mxshop-api/shared/auth"
)

func InitCategoryRouter(router *gin.RouterGroup) {
	signingKey := global.ServerConfig.SigningKey
	CategoryRouter := router.Group("/category")
	{
		CategoryRouter.GET("", category.List)
		CategoryRouter.GET("/:id", category.Detail)
		CategoryRouter.POST("", auth.Middleware(signingKey), auth.IsAdminUser(), category.New)
		CategoryRouter.PUT("/:id", auth.Middleware(signingKey), auth.IsAdminUser(), category.Update)
		CategoryRouter.DELETE("/:id", auth.Middleware(signingKey), auth.IsAdminUser(), category.Delete)
	}
}
